package com.atguigu.dga.governance.mapper;

import com.atguigu.dga.governance.bean.GovernanceAssessGlobal;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 治理总考评表 Mapper 接口
 * </p>
 *
 * @author wuzhida
 * @since 2024-07-02
 */
@Mapper
@DS("dga")
public interface GovernanceAssessGlobalMapper extends BaseMapper<GovernanceAssessGlobal> {

    @Select("SELECT \n" +
            "\tassess_date,\n" +
            "\tAVG(score_spec_avg) score_spec,\n" +
            "\tAVG(score_storage_avg) score_storage,\n" +
            "\tAVG(score_calc_avg) score_calc,\n" +
            "\tAVG(score_quality_avg) score_quality,\n" +
            "\tAVG(score_security_avg) score_security,\n" +
            "\tAVG(score_on_type_weight) score,\n" +
            "\tCOUNT(*) table_num,\n" +
            "\tSUM(problem_num) problem_num,\n" +
            "\tNOW() create_time\n" +
            "FROM governance_assess_table\n" +
            "WHERE assess_date = #{assessDate}\n" +
            "GROUP BY \n" +
            "\tassess_date;")
    List<GovernanceAssessGlobal> getGlobalScore(String assessDate);
}
